export default {
	data() {
		return {
            detail_data:{},
            id:'',
            radio:'1'
		}
	},
	
	//进入页面加载
	mounted: function() {
		var that = this;
		//在缓存中获取值
		that.user_name = sessionStorage.getItem("user_name");
		that.user_id = sessionStorage.getItem("user_id");
		that.token = sessionStorage.getItem("access-token");
		if((!that.token) || (!that.user_id) || (!that.user_name)) {
			that.$router.push('/login');
		}
		if(that.$route.query.id) {
			that.id = that.$route.query.id;
		}
        that.detail()
	},

	//方法
	methods: {
        /**
         * 请求api
         */
        detail: function() {
            var that = this;
            //请求的数据
            var formData = {};
            formData.token = that.token;
            formData.order_id = that.id;
            //请求邀请者列表
            that.$http.post(that.adminApi.api_url + "/api/ordereval/svaluate", formData, {
                emulateJSON: true
            }).then(
                function(res) {
                    // 处理成功的结果
					that.detail_data = res.body;
					that.radio = that.detail_data.is_displayed.toString();
                },
                function() {
                    // 处理失败的结果
                    that.$message({
                        type: 'error',
                        message: `操作提示: ${ '处理异常' }`
                    });
                });
        },

        /**
         * 保存
         * @param e
         */
        save:function (e) {
            var that = this;
            //请求的数据
            var formData = {};
            formData.token = that.token;
            formData.order_id = e;
            formData.is_displayed = that.radio;

            //请求邀请者列表
            that.$http.post(that.adminApi.api_url + "/api/ordereval/is_display", formData, {
                emulateJSON: true
            }).then(
                function(res) {
                    // 处理成功的结果
                    that.$router.back(-1);
                },
                function() {
                    // 处理失败的结果
                    that.$message({
                        type: 'error',
                        message: `操作提示: ${ '处理异常' }`
                    });
                });
        },


        /**
         * 返回
         */
        cancelEvalute:function () {
            let that =this;
            that.$router.back(-1);
        }
    }
}